package com.ssy.lingxi.purchase.model.response;

import com.ssy.lingxi.purchase.entity.PurchaseProduct;
import com.ssy.lingxi.purchase.utils.NumberUtil;
import lombok.Getter;
import lombok.Setter;

/**
 * @author wyx
 * @version 2.0.0
 * @date 2021-10-29
 */
@Setter
@Getter
public class MaterialPageRes {
    /**
     * 关联的商品Id
     */
    private Long productId;

    /**
     * 关联商品的编号
     */
    private String productNo;

    /**
     * 商品名称
     */
    private String name;

    /**
     * 商品规格
     */
    private String spec;

    /**
     * 商品品类
     */
    private String category;

    /**
     * 商品品牌
     */
    private String brand;

    /**
     * 计价单位
     */
    private String unit;

    /**
     * 商品单价（订单价）
     */
    private String price;

    /**
     * 请购数量
     */
    private String quantity;

    /**
     * 可用数量
     */
    private String quantifiable;

    public MaterialPageRes(PurchaseProduct product) {
        this.productId = product.getProductId();
        this.productNo = product.getProductNo();
        this.name = product.getName();
        this.spec = product.getSpec();
        this.category = product.getCategory();
        this.price = NumberUtil.formatAmount(product.getPrice());
        this.brand = product.getBrand();
        this.unit = product.getUnit();
        this.quantity = NumberUtil.formatToInteger(product.getQuantity());
        this.quantifiable = NumberUtil.formatToInteger(product.getQuantity().subtract(product.getTransferQuantity()));
    }
}
